<template>
  <div>
    <!-- 搜索 -->
    <!-- 技术报告查询 - 维修工单选择 -->
<!--    <TopFilter :list="topFilterInit" :cols="3" :collapse="collapse" labelWidth="90" @filterChange="changeHandle"></TopFilter>-->
    <!-- table -->
    <FilterTable height="auto" selectionType="single" ref="table" :columns="columns" :params="fetchParams" :dataSource="list" :datakey="'records'" :onColumnsChange="columns => (this.columns = columns)" :onRowSelectChange="selectChange"> </FilterTable>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <multiuse-button type="primary" :click="saveDialog.bind()">添加</multiuse-button>
      <multiuse-button @click="closeDialog">关 闭</multiuse-button>
    </div>
  </div>
</template>
<script>
  import {  getPartList }  from '@/api/claim/dealer/ClaimApplication/index';
  import { dictionary } from '@/utils/dictMixin';
export default {
  props: ['type', 'finalPartRList'],
  mixins: [dictionary],
  data() {
    return {
      dataList: [],
      visible: false,
      visibleDrawer: false,
      collapse: false,
      infoId: null,
      // topFilterInit: this.topFilterInitFun(),
      flterValue: {}, //参数
      columns: this.creatHeader(),
      // fetchApi: getPartList,
      fetchParams: {
        // type : 55021001
      }, //ipa 接口
      list: [],
      selectedRows: [] //选中经销商
    };
  },
  created() {
    console.log("#!#!!",this.finalPartRList)
    // this.$refs.table.$refs.pageTable.EXECUTE_INSERT(this.finalPartRList);
    this.list = [...this.finalPartRList]
  },
  methods: {
    //搜索数据
    // topFilterInitFun() {
    //   return [
    //     { type: 'INPUT', label: '配件代码', fieldName: 'vin', placeholder: '请输入', initialValue: '' },
    //     { type: 'INPUT', label: '配件名称', fieldName: 'vin', placeholder: '请输入', initialValue: '' }
    //   ];
    // },
    //搜索获取数据
    changeHandle(val) {
      this.fetchParams = val;
      console.log(val);
    },
    //table表头和数据源
    creatHeader() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        { title: '配件代码', dataIndex: 'partCode', sorter: true },
        { title: '配件名称', dataIndex: 'partName', sorter: true },
        { title: '单位', dataIndex: 'partUnit', sorter: true },
        { title: '数量', dataIndex: 'partCount', sorter: true },
        { title: '索赔单价', dataIndex: 'cmsClaimPrice', sorter: true },
        { title: '索赔总价', dataIndex: 'cmsClaimAmount', sorter: true },
        { title: '返件类型', dataIndex: 'returnType', sorter: true, dictItems: this.createDictList('5585') },

      ];
    },
    //选中
    selectChange(rows) {
      this.selectedRows = rows;
      console.log(this.selectedRows);
    },
    //保存
    saveDialog() {
      this.$emit('save', this.selectedRows);
    },
    //取消操作
    closeDialog() {
      this.$emit('close', { visible: false, data: this.selectedRows, type: 'close' });
    },
    chooseOrderNo() {
      this.visible = true;
    }
  }
  // mounted() {
  //   this.BaseTable = this.$refs.listModal.$refs.pageTable;
  // }
};
</script>

<style lang="less" scoped></style>
